package com.tk.exam.utils;

import lombok.Data;

import java.util.List;


@Data
public class PageInfo<T> {

    //当前页
    private int currentPage;
    //分页单位
    private int pageSize;
    //总页数
    private int totalPages;
    //全纪录
    private long totalRecords;
    //data
    private List<T> list;


    public PageInfo() {
        //empty
    }

    public PageInfo(int totalRecords, List<T> list) {
        this.totalRecords = totalRecords;
        this.list = list;
    }

    public PageInfo(int currentPage, int pageSize, int totalPages, long totalRecords, List<T> list) {
        this.currentPage = currentPage;
        this.pageSize = pageSize;
        this.totalPages = totalPages;
        this.totalRecords = totalRecords;
        this.list = list;
    }

    public PageInfo(com.github.pagehelper.PageInfo<T> pageInfoHelper) {
        this.currentPage = pageInfoHelper.getPageNum();
        this.pageSize = pageInfoHelper.getPageSize();
        this.totalPages = pageInfoHelper.getPages();
        this.totalRecords = pageInfoHelper.getTotal();
        this.list = pageInfoHelper.getList();
    }

    public PageInfo(com.github.pagehelper.PageInfo<T> pageInfoHelper, List<T> list) {
        this.currentPage = pageInfoHelper.getPageNum();
        this.pageSize = pageInfoHelper.getPageSize();
        this.totalPages = pageInfoHelper.getPages();
        this.totalRecords = pageInfoHelper.getTotal();
        this.list = list;
    }

}
